package com.qys.livesMall.shop.controller.sys;

import com.qys.livesMall.common.result.R;
import com.qys.livesMall.shop.modal.dto.shop.level.ShopLevelSaveDTO;
import com.qys.livesMall.shop.modal.vo.ShopLevelVO;
import com.qys.livesMall.shop.service.H2ShopLevelService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 后台管理-店铺等级管理
 *
 * @author wzy
 * @since 2023-04-05
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/web/shop-level")
public class WebH2ShopLevelController {

    private final H2ShopLevelService shopLevelService;

    /**
     * 店铺等级列表
     * @return
     */
    @GetMapping(value = "/all")
    public R<List<ShopLevelVO>> all() {
        return R.ok(shopLevelService.list());
    }



    @Operation(summary = "新增店铺等级")
    @PutMapping(value = "/add")
    public R<?> add(@RequestBody @Validated ShopLevelSaveDTO params) {
        shopLevelService.saveOrUpdate(params);
        return R.ok();
    }

    @Operation(summary = "修改店铺等级")
    @PutMapping(value = "/put")
    public R<?> put(@RequestBody @Validated ShopLevelSaveDTO params) {
        shopLevelService.saveOrUpdate(params);
        return R.ok();
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping(value = "/{id}")
    public R<?> delete(@PathVariable Integer id){
       return shopLevelService.delete(id);
    }

}
